package com.gs.zhss.eshop.auth.service.impl;

import com.gs.zhss.eshop.auth.dao.PriorityDAO;
import com.gs.zhss.eshop.auth.domain.PriorityDO;
import com.gs.zhss.eshop.auth.domain.PriorityDTO;
import com.gs.zhss.eshop.auth.service.PriorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: gs
 * @Date: 2023/12/24 15:52
 * @Version: v1.0.0
 * @Description: TODO
 **/
@Service
public class PriorityServiceImpl implements PriorityService {

    /**
     * 权限管理模块的DAO组件
     */
    @Autowired
    private PriorityDAO priorityDAO;

    /**
     * 查询根权限
     * @return 根权限集合
     */
    public List<PriorityDTO> listRootPriorities() {
        List<PriorityDO> priorityDOs = priorityDAO.listRootPriorities();

        List<PriorityDTO> priorityDTOs = new ArrayList<PriorityDTO>(priorityDOs.size());
        for(PriorityDO priorityDO : priorityDOs) {
            priorityDTOs.add(priorityDO.clone(PriorityDTO.class));
        }

        return priorityDTOs;
    }

}
